package com.cloud;


public class Main {

	public static void main(String arg[]){
        @SuppressWarnings("resource")
        java.util.Scanner sc = new java.util.Scanner(System.in);
        Integer n = sc.nextInt(); 
        Integer a[] = new Integer[n];
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
        }
        Integer niu = 0;
        Integer max = 0;
    	int pos = 0;
        for(int i=0;i<n;i++){
        	pos = i;
        	max = 0;
        	for(int j=i;j<n;j++){
            	if(a[j]>max){
            		max = a[j];
            		pos = j;
            	}
        	}
        	a[pos] = a[i];
        	if(i%2==0){
        		niu+=max;
        	}
        	else{
        		niu-=max;
        	}
        }
        System.out.println(niu);
	}
}
